<template>
	<view class="container">
		<view class="header">
			<text class="header-title">密码管理工具箱</text>
			<text class="header-subtitle">安全·便捷·高效</text>
		</view>
		<view class="tools-grid">
			<view class="tool-card" @click="navigateTo('/pages/list/list')">
				<text class="tool-icon">🔑</text>
				<text class="tool-title">密码管理</text>
				<text class="tool-desc">保存和管理你的密码</text>
			</view>
			<view class="tool-card" @click="navigateTo('/pages/generator/generator')">
				<text class="tool-icon">🛠️</text>
				<text class="tool-title">密码生成</text>
				<text class="tool-desc">一键生成强密码</text>
			</view>
			<view class="tool-card" @click="checkPasswordStrength">
				<text class="tool-icon">🔍</text>
				<text class="tool-title">强度检测</text>
				<text class="tool-desc">检测密码安全性</text>
			</view>
			<view class="tool-card" @click="backupData">
				<text class="tool-icon">💾</text>
				<text class="tool-title">数据备份</text>
				<text class="tool-desc">导出/导入密码数据</text>
			</view>
			<view class="tool-card" @click="navigateTo('/pages/settings/settings')">
				<text class="tool-icon">⚙️</text>
				<text class="tool-title">设置</text>
				<text class="tool-desc">应用偏好设置</text>
			</view>
		</view>
		<!-- 安全提示 -->
		<view class="security-tips">
			<view class="section-title">安全提示</view>
			<view class="tips-list">
				<view class="tip-item">
					<text class="tip-icon">🔒</text>
					<text class="tip-text">备份文件包含敏感信息，请妥善保管</text>
				</view>
				<view class="tip-item">
					<text class="tip-icon">☁️</text>
					<text class="tip-text">云备份数据经过加密，确保安全性</text>
				</view>
				<view class="tip-item">
					<text class="tip-icon">🔄</text>
					<text class="tip-text">定期备份数据，防止数据丢失</text>
				</view>
			</view>
		</view>
		<!-- <view class="recent-section">
			<view class="section-header">
				<text class="section-title">最近使用</text>
				<text class="section-more" @click="navigateTo('/pages/list/list')">更多</text>
			</view>
			<view class="recent-list">
				<view class="recent-item" v-for="(item, idx) in recentPasswords" :key="idx">
					<text class="recent-icon">🔑</text>
					<view class="recent-info">
						<text class="recent-title">{{item.title}}</text>
						<text class="recent-username">{{item.username}}</text>
					</view>
					<view class="recent-action">
						<text class="copy-btn" @click="copyPassword(item)">复制</text>
					</view>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
export default {
	data() {
		return {
			recentPasswords: [
				{ title: '百度', username: 'user1', password: '123456' },
				{ title: '邮箱', username: 'user2', password: 'abcdef' }
			],
			currentTheme: 'light'
		}
	},
	computed: {
		themeClass() {
			return `theme-${this.currentTheme}`
		}
	},
	onShow() {
		// 进入页面时同步主题
		
		this.currentTheme = uni.getStorageSync('setting_themeValue') || 'light'
	},
	methods: {
		navigateTo(url) {
			uni.navigateTo({ url })
		},
		generatePassword() {
			uni.showToast({ title: '敬请期待', icon: 'none' })
		},
		checkPasswordStrength() {
			uni.navigateTo({ url: '/pages/strength/strength' })
		},
		backupData() {
			uni.navigateTo({ url: '/pages/backup/backup' })
		},
		copyPassword(item) {
			uni.setClipboardData({
				data: item.password,
				success: () => {
					uni.showToast({ title: '已复制', icon: 'success' })
				}
			})
		}
	}
}
</script>

<style>
.container {
	padding: 30rpx;
}
.header {
	text-align: center;
	margin-bottom: 40rpx;
}
.header-title {
	font-size: 48rpx;
	font-weight: bold;
	color: #333;
}
.header-subtitle {
	font-size: 28rpx;
	color: #888;
	margin-top: 10rpx;
}
.tools-grid {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
}
.tool-card {
	width: 48%;
	background: #fff;
	border-radius: 16rpx;
	box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05);
	margin-bottom: 24rpx;
	padding: 32rpx 0;
	display: flex;
	flex-direction: column;
	align-items: center;
}
.tool-icon {
	font-size: 60rpx;
	margin-bottom: 12rpx;
}
.tool-title {
	font-size: 32rpx;
	font-weight: 500;
}
.tool-desc {
	font-size: 24rpx;
	color: #aaa;
	margin-top: 4rpx;
}
.recent-section {
	margin-top: 40rpx;
}
.section-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16rpx;
}
.section-title {
	font-size: 32rpx;
	font-weight: bold;
}
.section-more {
	font-size: 24rpx;
	color: #007aff;
}

.recent-item {
	display: flex;
	align-items: center;
	background: #f7f7f7;
	border-radius: 12rpx;
	padding: 20rpx;
	margin-bottom: 16rpx;
}
.recent-icon {
	font-size: 40rpx;
	margin-right: 20rpx;
}
.recent-info {
	flex: 1;
}
.recent-title {
	font-size: 28rpx;
	font-weight: 500;
}
.recent-username {
	font-size: 24rpx;
	color: #888;
}
.copy-btn {
	color: #007aff;
	font-size: 28rpx;
}
/* 安全提示 */
.security-tips {
	margin-bottom: 40rpx;
}

.tips-list {
	background: #fff;
	border-radius: 12rpx;
	padding: 30rpx;
	box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05);
}

.tip-item {
	display: flex;
	align-items: center;
	padding: 15rpx 0;
	border-bottom: 1rpx solid #f0f0f0;
}

.tip-item:last-child {
	border-bottom: none;
}

.tip-icon {
	font-size: 28rpx;
	margin-right: 15rpx;
}

.tip-text {
	font-size: 26rpx;
	color: #333;
	flex: 1;
}
</style>
